#include "gles_debug.h"

void eglCheckError_(const char *file, int line)
{
	EGLint errorCode;
	while ((errorCode = eglGetError()) != EGL_SUCCESS)
	{
		std::string error;
		switch (errorCode)
		{
			case EGL_NOT_INITIALIZED:                  	error = "EGL_NOT_INITIALIZED"; break;
			case EGL_BAD_ACCESS:                  		error = "EGL_BAD_ACCESS"; break;
			case EGL_BAD_ALLOC:                		error = "EGL_BAD_ALLOC"; break;
			case EGL_BAD_ATTRIBUTE:             		error = "EGL_BAD_ATTRIBUTE"; break;
			case EGL_BAD_CONTEXT:                		error = "EGL_BAD_CONTEXT"; break;
			case EGL_BAD_CONFIG:               		error = "EGL_BAD_CONFIG"; break;
			case EGL_BAD_CURRENT_SURFACE:         		error = "EGL_BAD_CURRENT_SURFACE"; break;
			case EGL_BAD_DISPLAY: 				error = "EGL_BAD_DISPLAY"; break;
			case EGL_BAD_SURFACE:                  		error = "EGL_BAD_SURFACE"; break;
			case EGL_BAD_MATCH:                  		error = "EGL_BAD_MATCH"; break;
			case EGL_BAD_PARAMETER:                 	error = "EGL_BAD_PARAMETER"; break;
			case EGL_BAD_NATIVE_PIXMAP:             	error = "EGL_BAD_NATIVE_PIXMAP"; break;
			case EGL_BAD_NATIVE_WINDOW:                	error = "EGL_BAD_NATIVE_WINDOW"; break;
			case EGL_CONTEXT_LOST:               		error = "EGL_CONTEXT_LOST"; break;
		}
        std::string result = error + " | " + file + " (" + line + ") ";
        NDK_LOGD("gles_debug", result.c_str());
    }
}